export default {
    set: (key, value, options) => { 
        var cookieText = encodeURIComponent(key) + '=' + encodeURIComponent(value);
        Object.keys(options).forEach(item=>{
            cookieText+=`;${item}=${options[item]}`
        })
        
        document.cookie = cookieText;
    },
    get: (key) => {
        const  cookieName= encodeURIComponent(key) + "="
        const  cookieStart=document.cookie.indexOf(cookieName)
           let cookieValue=''
        if (cookieStart > -1) {
            var cookieEnd = document.cookie.indexOf(";", cookieStart);
            if (cookieEnd == -1) {
                cookieEnd = document.cookie.length;
            }
            cookieValue = decodeURIComponent(document.cookie.substring(cookieStart + cookieName.length, cookieEnd));
        }
        return cookieValue;
    },
    remove: (key) => {
        this.set(key, "", {
            maxAge:0
        });
     }
}